package san.entity.m;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.orm.BaseEntity;

@Entity
@Table(name = "meal_order")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Order extends BaseEntity {

	/**
	 * 订单
	 */
	private static final long serialVersionUID = -2893817743172782301L;
	private String fromName;// 订单人姓名
	private String fromAddress;// 订单人地址
	private String fromTelphone;// 订单人电话
	private String toInfo;// 收货人信息
	private String userId;// 用户ID
	private Integer amount;// 数量
	private String discount;// 折扣
	private Double price;// 单价
	@Transient
	private Double subtotal;// 小计
	@Temporal(value = TemporalType.TIMESTAMP)
	private Date toTime = new Date();// 送货时间
	private String state;// 状态
	@ManyToOne(cascade = CascadeType.REFRESH, optional = false)
	@JoinColumn(name = "product_id")
	private Product product;

	public String getFromName() {
		return fromName;
	}

	public void setFromName(String fromName) {
		this.fromName = fromName;
	}

	public String getFromAddress() {
		return fromAddress;
	}

	public void setFromAddress(String fromAddress) {
		this.fromAddress = fromAddress;
	}

	public String getFromTelphone() {
		return fromTelphone;
	}

	public void setFromTelphone(String fromTelphone) {
		this.fromTelphone = fromTelphone;
	}

	public String getToInfo() {
		return toInfo;
	}

	public void setToInfo(String toInfo) {
		this.toInfo = toInfo;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public Integer getAmount() {
		return amount;
	}

	public void setAmount(Integer amount) {
		this.amount = amount;
	}

	public String getDiscount() {
		return discount;
	}

	public void setDiscount(String discount) {
		this.discount = discount;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Date getToTime() {
		return toTime;
	}

	public void setToTime(Date toTime) {
		this.toTime = toTime;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public Double getSubtotal() {
		return price * amount;
	}

	public void setSubtotal(Double subtotal) {
		this.subtotal = subtotal;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

}
